﻿@model List<Wicresoft.SelfService.DAO.ClassifyConfig>
@using Wicresoft.SelfService.DAO
@{
    ViewBag.Title = "分类维护";
    Layout = "~/Views/Shared/_ClassifyConfigLayout.cshtml";
}

<script type="text/javascript">
        $(document).ready(function(){
            var url="@Url.Action("CreateClassify","ServiceMaintain")";
            $("#rightpart").load(url);
        });
        function getClassifyInfo(id) {
            var currentID = id;
            var url="@Url.Action("ShowClassify", "ServiceMaintain")";
            url += "?ID="+currentID;
            $("#rightpart").load(url);
        }
        function getCreatePage(){
            var url="@Url.Action("CreateClassify","ServiceMaintain")";
            $("#rightpart").load(url);
        }
 </script>

<div class="center">
    <div class="box">
        <div class="main_left">
            <div class="headpart ui-icons">
            </div>
            @{
                Dictionary<string, List<ClassifyConfig>> dic = new Dictionary<string, List<ClassifyConfig>>();
                foreach (var classify in Model)
                {
                    if (classify.ServiceID == 0)
                    {
                        dic.Add(classify.PartialName, new List<ClassifyConfig>());
                    }
                }
                foreach (var classify in Model)
                {
                    if (classify.ID != 0)
                    {
                        dic[classify.PartialName].Add(classify);
                    }
                }
                    
                      
                }
            <div class="left_menu">
                <div class="left_menu_border">
                    <a href="#" id="createUrl" onclick="getCreatePage();">
                       <input type="button" id="CrtBD" value="创建选择分类" style=" height:30px; width:193px; font-weight:bold;" />
                    </a>
                </div>
                <hr />
                @{int i = 1;}
                @foreach (KeyValuePair<string, List<ClassifyConfig>> kvp in dic)
                {
                    string partialName = kvp.Key;
                    string serviceName = "";
                    switch (partialName)
                    {
                        case "Desktop": serviceName = "桌面终端"; break;
                        case "NetworkAccess": serviceName = "网络接入"; break;
                        case "Antivirus": serviceName = "安全防病毒"; break;
                        case "Business": serviceName = "业务需求"; break;
                        case "VPN": serviceName = "VPN"; break;
                        case "Internal": serviceName = "内部请求"; break;
                        case "AppSystem": serviceName = "应用系统"; break;
                    }
                    
                    if (serviceName != "VPN" && serviceName != "内部请求")
                    {
                        var vid = "VNavParent" + i;
                        i++;
                        <div class="left_menu_border">
                            <div class="ui-icons VNavParentI" id="@vid" onclick="VNavParent(this);"> &nbsp;&nbsp;&nbsp;&nbsp; @serviceName 
                                <ul style="display: none;" id ="SD">
                                    @foreach (ClassifyConfig item in kvp.Value)
                                    {
                                        <li class="VNavLeaf">
                                           <a href="#" class="ui-icons" id="@(item.ID)" onclick="getClassifyInfo(@item.ID);getVNavLeaf(@i,this);" >
                                                @if (item.ServiceName.Length < 10)
                                                     {
                                                    <span title="@item.ServiceName">@item.ServiceName</span>
                                                }
                                                else{
                                                    var name1 = item.ServiceName.Substring(0, 10).ToString() + "...";
                                                    <span title="@item.ServiceName">@name1</span>
                                                }
                                           </a>
                                        </li>
                                    }
                                </ul>
                            </div>
                        </div>
                    }
                    
                } 
            

            </div>
        </div>
        <div class="main_right" id="rightpart" data-url="">
              
        </div>
    </div>
</div>


